package org.csmzxy.class2333;

public class example02 {
    public static void main(String[] args) {
        int n = 20;
        long sum = 0;
        long first = 1;
        long second = 1;
        long next;

        sum += first + second;

        for (int i = 3; i <= n; i++) {
            next = first + second;
            sum += next;
            first = second;
            second = next;
        }

        System.out.println("斐波那契数列前20项之和为: " + sum);
    }
}
